VB .NET Web Apps


1. You use Visual Studio .NET to create applications for a large Internet service organization that provides end-to-end web site design and hosting. You create an assembly that will reside on the IIS server. The assembly will be used by virtually all applications deployed on the server. You must ensure that any applications installed on the server will be able to access the assembly. (Choose all that apply)

A. Use the SN.EXE utility to create a strong name.
B. Install the application into the Global Assembly Cache.
C. Copy the application into the Global Assembly Cache.
D. Copy the application to the wwwroot folder on the web server.
E. Ensure that when the assembly is deployed it does not deploy to the Global Assembly Cache.

>> !
Answer: A & B

The Strong Name tool provides assemblies with a strong name to guarantee globally uniqueness.

The global assembly cache is a machine-wide accessible store for assemblies specifically designated to be shared by several applications on the computer.

An application must be installed into the Global Assembly Cache you can not simply perform a copy operation.

To deploy a web site you could copy the files to the wwwroot folder on the server but must install an assembly and it must be placed into the Global Assembly Cache.

Ensuring that when the assembly is deployed it does not deploy to the Global Assembly Cache is the opposite of what you want to accomplish.


2. You are working as a Visual Studio .NET consultant and your current contract has you implementing security for a large manufacturing organization, ACME Widgets. ACME has recently decided to standardize all development on the .NET framework. You need to configure role-based security for a component that will have three separate roles; Administration, DataEntry and ReadOnly. The roles will include individuals from separate groups in the corporate domain. How do you create the roles? (Choose all that apply)

A. Create a package in Component Services on the computer that will house the application.
B. Create the three roles and assign the necessary groups in the users folder.
C. Create database roles on the SQL Server and assign the necessary groups.
D. Have the application perform an Active Directory query for the user's group membership.
E. Use the application role mechanisms in SQL Server.

>> !
Answer: A & B

Component services can be found in the Administrative tools and is the replacement for the MTS environment. Each role configured in Component Services can be assigned user or group accounts from any trusted computer or domain controller.

SQL Server does support role based security in this fashion but it is not the proper technique for assigning role-based security to a component.

You could perform this activity but it is unnecessary and there are techniques built into the component services that already provide this functionality.

If the component is used to solely access the server this technique is useful for a database implementation but doesn't provide for multiple roles nor does it work outside of the context of the database server.


3. You are working as a Visual Studio .NET consultant and you current contract has you implementing security for a large manufacturing organization, ACME Widgets. ACME has recently decided to standardize all development on the .NET framework. You need to configure security for a web site that is only to be accessed by individuals within the company. The company is standardized on Internet Explorer 6 as its web browser. What type of security should you implement?

A. Custom application authentication.
B. Microsoft Passport.
C. Forms-based.
D. No Authentication (None).
E. Windows Authentication.

>> !
Answer: E

The Windows authentication provider relies upon IIS to perform the required authentication of a client based on a Windows logon process. It authenticates using Windows accounts on a computer or within a domain.

The Passport authentication provider offers a single logon and core profile services for member sites. Used primarily when Windows account information is not available or the same authentication is needed across any of the participating member sites.

The Forms authentication provider makes it possible for the application to collect credentials using an HTML form. It uses cookies as a way of maintaining the logon information within the users Internet cache.

No Authentication (None) would allow all access and is definitely not what is required.

Custom application authentication is far too much effort and is only used in instances where extra authentication measures must be taken as the application executes.


4. You are working as a Visual Basic .NET developer for a large Internet service organization that specializes in maintaining web sites for government offices. There are a considerable number of files requiring security against individuals who should not be viewing the information contained therein. One of the agencies reports that they cannot view data that should be available for public access. You verify the configuration settings and find the following entry in the Web config file:

password="pass"/>

You have strict instructions not to change any of the configuration files for the government web sites. How do you fix the problem?

A. Check the NTFS permissions of the files and ensure that the PublicAccess user is permitted to read the files in question
B. Check the Share permissions of the files and ensure that the PublicAccess user is permitted to read the files in question
C. Check the Web Sharing permissions of the files and ensure that the PublicAccess user is permitted to read the files in question
D. Configure the site in the IIS manager to allow anonymous access

>> !
Answer: A

When using impersonation the application relies on the NTFS permissions to secure all files. If those permissions do not permit reading of the file then access would be denied.

Share permissions have no effect when accessing files across the Internet. Share permissions are solely used when access files across a corporate network through the share.

When using impersonation the application relies on the NTFS permissions to secure all files. If those permissions do not permit reading of the file then access would be denied.

Configuring the site in the IIS manager to allow anonymous access could allow a user to access far more files then they should be able to and will not remedy the situation for the files in question.


5. You are developing a number of projects for a large manufacturing corporation, ACME Widgets. The system, when completed, will be integrated into a combination web-based and windows-based application environment. In the system you are using a 3-tier development process. Currently you are in the planning stages and you are attempting to determine for which application processes each program is to be responsible. You have a set of operations that will involve complex processing to determine the validity of the inputted data. Most of the required processing involves range checking. Where would these processes be performed? (Choose all that apply)

A. In a component that will be accessed by both the Windows-based applications and the Internet server processed.
B. Within the user interface of each application.
C. In one component that will be accessed by the Windows-based applications and a second component accessed by the Internet server processed.
D. As a stored procedure on a database serve.
E. <!-- #include virtual = filename -->.

>> !
Answer: A & D

The processes are business rules which should be separated from the user interface and the data services.

Because the business rules in these processes are not directly related to the data it is unlikely that they belong in stored procedures.

In one component that will be accessed by the Windows-based applications and a second component accessed by the Internet server processed. It is likely unnecessary to use two components in this example as a single component could be used by both application types.

Because this is a three-tier development and the processes are complex it makes more sense to separate the processing into middle tier business rules components.


6. You are one of a team of Visual Studio .NET developers working for a large Internet service provider. The current project you are developing uses ASP.NET technologies to provide a web-based application for your clients to interact with their own web sites. You are implementing code that must run at the server as opposed to the client browser. Which techniques are used to implement server-side code? (Choose all that apply)

A. <script runat="server" language="VB">
</script>
B. <% Code goes here... %>
C. <%-- Code goes here... --%>
D. <object id="id" runat=server latebinding=true>
E. <!-- #include virtual = filename -->

>> !
Answer: A & B

Code declaration blocks are defined using <script> tags that contain a runat attribute value set to "server" to indicate the code is to be executed at the server. <% Code goes here... %> defines inline code or inline expressions that execute on the server when the page is rendered.

<%-- Code goes here... --%> is a server side comment expression and can not contain code to be executed.

The Object ID tag is used to declare and create COM and .NET objects in a Web Forms page.

The Include will allow for you to insert the contents of a specified file anywhere within an ASP.NET page.


7. You are developing a number of projects for a large manufacturing corporation, ACME Widgets. The system, when completed, will be integrated into a combination web-based and windows-based application environment. In the system you are using a 3-tier development process. Currently you are in the planning stages and you are attempting to determine for which application processes each program is to be responsible. You have a set of operations that will involve complex processing to determine the validity of the inputted data. Most of the required processing involves range checking. Where would these processes be performed?

A. As a stored procedure on a database serve.
B. In a component that will be accessed by both the Windows-based applications and the Internet server processed.
C. In one component that will be accessed by the Windows-based applications and a second component accessed by the Internet server processed.
D. Within the user interface of each application.

>> !
Answer: B

The processes are business rules which should be separated from the user interface and the data services.

Because the business rules in these processes are not directly related to the data it is unlikely that they belong in stored procedures.

In one component that will be accessed by the Windows-based applications and a second component accessed by the Internet server processed. It is likely unnecessary to use two components in this example as a single component could be used by both application types.

Because this is a three-tier development and the processes are complex it makes more sense to separate the processing into middle tier business rules components.


8. You are developing a Web-based application that will serve up data items from a Microsoft SQL Server database that resides in your company's demilitarized zone. The application requires the alteration of items in a data list. The items must be wrapped on to the next line when the end of a cell is reached. Which of the following properties would be set?

A. Set the Separator.Template property
B. Set the SelectedItemStyle property
C. Set the ItemTemplate property
D. Set the Selected.ItemTemplate property
E. Set the ItemStyle property
F. Set the Separator.Style property

>> !
Answer: E

In the DataList Web server control, you set the appearance of items using properties of the ItemStyle objects.

In the DataList Web server control, you set the appearance of selected items using properties of the SelectedItemStyle objects.

Set the ItemTemplate property gets or sets the template for the items in the DataList control it does not directly control the display functionality.

Set the Selected.ItemTemplate property gets or sets the template for the selected items in the DataList control it does not directly control the display functionality.

Set the Separator.Template property interacts with the template of the separator between each item in the DataList control and does not directly control display functionality.

Set the Separator.Style property interacts with the style properties of the separator between each item in the DataList control.


9. You are working on a large web-based integration project that will use a number of backend database resources to implement data queries along with standard add, change delete functionality. The application you are currently working with will use Web forms with a number of user controls. You have used the following code to access one of the controls:

Public Class MyWebPage Inherits System.Web.UI.Page Protected myControl1 As WebUserControl1

How do you programmatically make the control visible?

A. myControl1.Show
B. WebUserControl1.Visible = True
C. Controls on a Web form are always visible
D. The visibility of Controls on a Web form always stays in their designed state
E. MyControl1.Visible = True
F. WebUserControl1.Show

>> !
Answer: E

Once declared a web controls properties can be set using the declared name.

WebUserControl1.Visible = True is the generic class name for the control and cannot be directly interacted with.

Like other controls a web form's controls visibility can be altered using the Visible property.

The Visible property should be used for visibility the Show method is used for formsand the generic WebUserControl1 should not be directly interacted with.


10. You are working as a Visual Studio .NET developer for a large Internet service organization. Your recent project is an ASP.NET application that will be used by you company's clientele. You want to perform a series of initialization processes the first time your application is accessed by each client. Where should the initialization code be placed?

A. Add code to the Session_OnStart event of the Global.asax file.
B. Add code to the Application_OnStart event of the Global.asax file.
C. Add code to the Form_Load event of the main project form.
D. Add code to the Form_InitializeComponent event of the main project form.

>> !
Answer: A

The Session_OnStart event is fired when a user accesses an ASP.NET application it is used to provide initialization of user activity.

The Application_OnStart event fires only once during the life of an application and therefore is unsuitable for user initialization.

This type of initialization is not suitable in this instance and would be best used to initialize elements of a Windows form.

In Visual Basic .NET, initialization code can be added to a form constructor (Sub New()) after the call to InitializeComponent().


11. You are a Visual Basic .NET developer who has been coding a Web application that will be used by a number of different cultures. You are in the final stages of localizing the product for each culture. You have the compiled application with support for Germany, Australia and Canada. You have set up the application to use the United States as a default culture. The team of developers with whom you work creates the necessary resource files. How do you now imbed a resource file into the assembly?

A. Use the Resource File generator to imbed a resource file.
B. Use the Assembly Linker to imbed a resource file.
C. Use the Isolated Storage tool to embed a resource file.
D. Use the Installer tool to imbed a resource file.
E. Use the MSIL Assembler tool to imbed a resource file.
F. Use the License Compiler to imbed a resource file.

>> !
Answer: B

The Assembly Linker generates a file with an assembly manifest from multiple files that are modules or resource files.

The Resource File Generator converts .txt files and .resx files to common language runtime binary. resources files.

The Isolated Storage tool lists or removes existing stores for a user.

The Installer tool allows you to install server resources by executing the installer components.

The MSIL Assembler generates a portable executable (PE) file from MSIL assembly language.

The License Compiler reads text files containing license data producing .licenses files that can be embedded in an executable as a resource.


12. You are developing an ASP.NET web application and you discover that none of the existing ASP.NET server controls meet the specific requirements of your application. You need to deploy the application quickly to service a web site that has already been in service. How should you develop the functionality?

A. Create a Web custom control to encapsulate the functionality.
B. Create a Web user control to encapsulate the functionality.
C. Create an ActiveX control to encapsulate the functionality.
D. Create a Web Service to encapsulate the functionality.

>> !
Answer: B

Web user controls are easy to make, but they can be difficult to use for the inexperienced developer.

Web custom controls are compiled code, which makes them easier to use but more difficult to create then web user controls.

Creating an ActiveX control to encapsulate the functionality is a good solution when working on the client side, yet the indication of server side controls makes it a poor choice.

ASP.NET Web services rely on the System.Xml.Serialization.XmlSerializer class to marshal data to and from SOAP messages at runtime and are an application specific that could not provide the desired functionality.


13. You work as a Visual Studio .NET developer for a large Internet service organization. You are training a new developer and need to explain the differences between Web User Controls and Web Custom Controls. Which of the following statements are true? (Choose all that apply)

A. Web User Controls have limited design support while Web Custom Controls have full visual design support.
B. Web user controls require a separate copy of the control in each application while Web custom controls require a single copy of the control for all applications.
C. Web user controls cannot be added to the Toolbox in Visual Studio while Web custom controls can be added to the Toolbox.
D. Web user controls can be added to the Toolbox in Visual Studio while Web custom controls cannot be added to the Toolbox.
E. Web user controls require a single copy of the control for all applications while Web custom controls require a separate copy of the control for each application.
F. Web User Controls have full visual design support while Web Custom Controls have limited design support.

>> !
Answer: A, B & C

Web User Controls have limited design support while Web Custom Controls have full visual design support. Web user controls have limited support for consumers who use a visual design tool while Web custom controls have full visual design tool support for consumers. Web user controls require a separate copy of the control in each application while only a single copy of a Web custom control is required, in the global assembly cache. Web user controls cannot be added to the Toolbox in Visual Studio while Web custom controls can be added to the Toolbox.

Web user controls cannot be added to the Toolbox in Visual Studio while Web custom controls can be added to the Toolbox.

Web user controls require a separate copy of the control in each application while only a single copy of a Web custom control is required, in the global assembly cache.

Web user controls have limited support for consumers who use a visual design tool while Web custom controls have full visual design tool support for consumers.


14. You are working as a Visual Studio .NET developer for a large Internet service organization that specializes in end-to-end development and deployment of ecommerce web sites for small businesses. You are working on an ASP.NET application that is coded primarily in C# but are supplying a page of the application using Visual Basic .NET. What is needed to accommodate the functionality?

A. Refer to the page in the Global.asa file as a VB pages
B. This cannot be done, you must translate the page to C#
C. Supply an @ Page directive indicating the language
D. Use a separate Web.config file for the page that supplies the needed language information

>> !
Answer: C

The @Page directive defines page-specific attributes used by the ASP.NET.

The whole purpose behind the single runtime engine is to allow you to combine languages and create complete systems that are not language specific.

The Global.asa file supplies information for the entire application, not a single page. The @Page directive defines page-specific attributes used by the ASP.NET.

The Web.config file is an XML file that describes and controls the configuration of the application.


15. You are developing an ASP.NET application for a large Internet service organization that provides end-to-end development, deployment and hosting of ecommerce web site for small businesses. You would like to send HTTP output that has been prepared from the sting concatenation of a number of elements to the user's browser. The output could potentially include formatting, hyperlinks and graphical material. What code would you implement?

A. <% Response.Redirect (OutputToBrowser) %>
B. <% Response.Redirect %> OutputToBrowser
C. <% Response.Write %> OutputToBrowser
D. <% Response.Write OutputToBrowser %>

>> !
Answer: D

Use the Response.Write method to sent HTP output to the user's browser.

<% Response.Redirect %> OutputToBrowser would redirect the user to an alternate site stored in the variable and the variable should be included in the server directive.

The built variable should be included inside the server directive


16. You are working as a Visual Basic .NET developer for a large manufacturing company, ACME Widgets. You are developing a COM component that will be installed on an IIS server and accessed from an ASP.NET procedure. You need to create a custom event that will signal the ASP.NET application when the logon process has completed. Which of the following code fragments is the correct implementation?

A.
Event LogonCompleted(UserName As String)
Sub LogonDone RaiseEvent LogonCompleted("Billy Bean")
End Sub
B.
Friend WithEvents MyComponentImplemented As MyComponent
Protected Sub MyComponentImplemented_LogonCompleted(UserName As String) Handles MyComponent.LogonCompleted 'Implementation code here
EndSub
C.
AddHandler MyComponent.LogonCompleted, AddressOf Me.MyEventHandler
Sub MyEventHandler() ' Implementation Code
End Sub
D.
Sub TestEvents() Dim Obj As New MyComponent
AddHandler Obj.LogonCompleted, AddressOf EventHandler
Obj.LogonDone() RemoveHandler Obj.Ev_Event, AddressOf EventHandler
End Sub

>> !
Answer: A

To create and raise an event declare the event and the parameters (if any) that it uses.

Friend WithEvents MyComponentImplemented As MyComponent
Protected Sub MyComponentImplemented_LogonCompleted(UserName As String) Handles MyComponent.LogonCompleted 'Implementation code here
EndSub
is a possible client side code for the ASP.NET application and not the correct component code.

AddHandler MyComponent.LogonCompleted, AddressOf Me.MyEventHandler
Sub MyEventHandler() ' Implementation Code
End Sub
is possible client side code for the ASP.NET application and not the correct component code.

Sub TestEvents() Dim Obj As New MyComponent
AddHandler Obj.LogonCompleted, AddressOf EventHandler
Obj.LogonDone() RemoveHandler Obj.Ev_Event, AddressOf EventHandler
End Sub
is client side code that you might find in the ASP .NET application that starts and stops event handling.


17. You are working as a Visual Basic .NET developer for a large manufacturing company, ACME Widgets. You are developing an ASP.NET applications that uses a COM component installed on an IIS server. You need to create an event handler that will write to the application log when the logon process has completed. Once the event has been handled you need to stop handling the events from the component. Which of the following code fragments is the correct implementation?

A.
Sub TestEvents()
Dim Obj As New MyComponent
AddHandler Obj.LogonCompleted, AddressOf MyEventHandler
Obj.LogonDone()
RemoveHandler Obj.Ev_Event, AddressOf MyEventHandler
End Sub
Sub MyEventHandler()
' Implementation Code
End Sub
B.
Friend WithEvents MyComponentImplemented As MyComponent
Protected Sub MyComponentImplemented_LogonCompleted(UserName As String) Handles MyComponent.LogonCompleted
'Implementation code here
End Sub
C.
AddHandler MyComponent.LogonCompleted, AddressOf Me.MyEventHandler

Sub MyEventHandler()
' Implementation Code

End Sub
D.
Event LogonCompleted(UserName As String)

Sub LogonDone
RaiseEvent LogonCompleted("Billy Bean")

End Sub

>> !
Answer: A

This is client side code that you might find in the ASP .NET application that starts and stops event handling.

Friend WithEvents MyComponentImplemented As MyComponent
Protected Sub MyComponentImplemented_LogonCompleted(UserName As String) Handles MyComponent.LogonCompleted
'Implementation code here
End Sub
is possible client side code for the ASP.NET application for trapping the event. However, once the event is fired the application will still handle future events.

AddHandler MyComponent.LogonCompleted, AddressOf Me.MyEventHandler

Sub MyEventHandler()
' Implementation Code

End Sub
is possible client side code for the ASP.NET application for trapping the event. However, once the event is fired the application will still handle future events.

Event LogonCompleted(UserName As String)

Sub LogonDone
RaiseEvent LogonCompleted("Billy Bean")

End Sub
is an example of what you might find in the component itself.


18. You are working as a member of a team of Visual Studio .NET developers for a large Internet service organization that provides end-to-end design and deployment of eCommerce web sites for a variety of small businesses. The current application that your team is working on requires the implementation of online user assistance. You plan to use an HTML help engine to provide assistance to the users. You would like first to display an HTML table of contents for the user. What code would provide this functionality?

A.
<OBJECT id=MyControl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"
codebase="HHCTRL.ocx#Version=4,72,8252,0" width=100% height=100%>
<PARAM name="Command" value="Contents">
<PARAM name="Item1" value="C:\Mytoc.hhc">
<PARAM name="Flags" value="0x4000,0x800035>
</OBJECT>
B.
<OBJECT
id=MyControl
type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"
codebase="HHCTRL.ocx#Version=4,72,8252,0"
width=100
height=100
>
<PARAM name="Command" value="HH Version">
<PARAM name="Button" value="Text:Click for version number">
</OBJECT>
C.
<OBJECT
id=MyControl
type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"
codebase="HHCTRL.ocx#Version=4,72,8252,0"
width=100
height=100
>
<PARAM name="Command" value="Index">
<PARAM name="Item1" value=".hhk file path">
</OBJECT>
D.
OBJECT
id=MyControl
type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"
codebase="HHCTRL.ocx#Version=4,72,8252,0"
width=100
height=100
>
<PARAM name="Command" value="KLink, menu">
<PARAM name="Button" value="Text:Animal Diets">
<PARAM name="Item1" value="animals.chm">
<PARAM name="Item2" value="omnivore">
<PARAM name="Item3" value="carnivore">
</OBJECT>

>> !
Answer: A

The contents command creates a graphical table of contents that displays a specified contents file.

The HHVersion command is used to display the version number of the HTML Help ActiveX control in a dialog box.

The Index command is used to creates a graphical index that displays a specified index file.

The Klink command is used to provide a Keywords list.


19. You have developed an Interface for a customer object with the following code:

Interface IcustomerInfo
Property CustomerName() As String
Sub UpdateCustomerStatus()
Event UpdateComplete()
End Interface

You would like to extend the class so that you can have two different types of customer objects built off this basic template, one for service customers and one for product customers. How would you accomplish this?

A. Create two new classes ProductCustomer and ServiceCustomer. Use the Implements statement to build upon the base Customer class.
B. Create a new class for ProductCustomer use the Implements statement to build upon the base Customer class. Create a new class for ServiceCustomer use the Implements statement to build upon the ProductCustomer class.
C. Create a new class for ServiceCustomer use the Implements statement to build upon the base Customer class. Create a new class for ProductCustomer use the Implements statement to build upon the ServiceCustomer class.
D. Create two new classes ProductCustomer and ServiceCustomer. Copy the cope from the Customer class as a template to use in your two new classes.

>> !
Answer: A

The Implements statement allows you to specify one or more interfaces, or interface members, that will be implemented in the class or structure definition in which it appears.

Both new classes should be based on the Customer class. The Service customer is not intended to be a subclass of the product customer.

The Implements statement can be used instead of a manual copy operation because it allows you to specifies one or more interfaces, or interface members, that will be implemented in the class or structure definition in which it appears.


20. You have developed an fully coded class for a customer object that has:

Property CustomerName() As String
Sub UpdateCustomerStatus()
Event UpdateComplete()

You would like to extend the class so that you can have two different types of customer objects built off this basic template, one for service customers and one for product customers. How would you accomplish this?

A. Create two new classes and use the Implements statement to allow you to have access to the already coded customer class.
B. Create two new classes and use the Inherits statement to allow you to have access to the already coded customer class.
C. Create two new classes and use the Imports statement to allow you to have access to the already coded customer class.
D. Create two new classes and use the Interface statement to allow you to have access to the already coded customer class.

>> !
Answer: B

The Inherits statement uses the two new classes to inherit the attributes, fields, properties, methods, and events from the customer class.

The implements statement only inherits the interfaces not the code.

The imports statement allows you to imports namespace names from referenced projects and assemblies. Also imports namespace names defined within the same project as the file in which the statement appears allowing a shorter technique to coding.

The interface statement allows you to create a template of a class with no implementation code.


21. You are creating a financial application that performs a number of complex calculations. The variable declarations for the program are as follows:

Public I=1, J=2, K=3 As Integer
Public S, SArray() As Short
Public B1, B2 As Byte
Public C1, C2 As Char

You receive an error message when you execute the following command: B1 = I + J + K

How can you correct the problem?

A. Set Strict off
B. Convert all numeric variables to Decimal
C. Set Option Explicit on

>> !
Answer: A

The likely cause of the problem is variable narrowing. Strict should be off if the narrowing will not cause loss of data. If you set strict off then you are allowed to perform calculations that store the result into variables of a smaller size (narrowing).

The error is likely occurring because strict conversion is on, in which case you need not change any of the data types if the narrowing will not cause loss of data.

Set Option Explicit on will only force you to declare variables before their use that the code is already doing.


22. You are troubleshooting the code from another member of your development team and notice the following results:

Dim Names() As String = New String(3) {"Name0", "Name1", "Name2", "Name3"}
MyArray = Names ' Fails at compile time.

What is the cause of the problem?

A. You must have the same number of entries when performing an array conversion
B. Myarray is not declared
C. Myarray is an object array
D. Option Strict is set on

>> !
Answer: A

You can convert an array type to a different array type provided you have the same number of elements in each array, variable types must be reference types, widening or narrowing must be available (the types must have something in common)

"Myarray is not declared" would be right if Option Explicit were off.

Myarray is an object array is fine providing the widening or narrowing is possible. In other words it is possible to store a sting into an object.

'Option Strict is set on' is not right because the conversion would be a widening of the data not a narrowing.


23. You are working as a developer for a hobby machinery manufacturer. Shizoo Manufacturing Inc. The company manufactures and sells a variety of snowmobiles and equipment as well in the future it plans on releasing the new Jezoo Sea Ski. The model will be available in standard colors. The application you are developing must present these colors on the interface upon selection from a dropdown list box. Which of the following would be used define a set of named constants for the color schemes?

A.
Public Enum InterfaceColors
MistyRose = &HE1E4FF&
SlateGray = &H908070&
DeepSkyBlue = &HFFBF00& ForestGreen = &H228B22&
End Enum
B.
Public Const InterfaceColors
MistyRose = &HE1E4FF&
SlateGray = &H908070&
DeepSkyBlue = &HFFBF00& ForestGreen = &H228B22&
End Const
C.
Public Sub InterfaceColors
Const MistyRose = &HE1E4FF&
Const SlateGray = &H908070&
Const DeepSkyBlue = &HFFBF00&
Const ForestGreen = &H228B22&
End Sub
D.
Public Function InterfaceColors( Choice as string) As Color
Select Case Choice
Case "MistyRose" InterfaceColors = &HE1E4FF&
Case "SlateGray"
InterfaceColors = &H908070&
Case "DeepSkyBlue"
InterfaceColors = &HFFBF00&
Case Else
InterfaceColors = &H228B22&
End Select
End Function

>> !
Answer: A

Enum is used at a module, class, or structure level to declare enumeration constants and define the values of its members.

Const is used for declaring singular constants, an enumeration must be used for multiple values.

Public Sub InterfaceColors
Const MistyRose = &HE1E4FF&
Const SlateGray = &H908070&
Const DeepSkyBlue = &HFFBF00&
Const ForestGreen = &H228B22&
End Sub
in theory would work. However, you would have to declare separate constant for each color that was created in the future. This could be an arduous update task if the colors every change.

Public Function InterfaceColors( Choice as string) As Color
Select Case Choice
Case "MistyRose" InterfaceColors = &HE1E4FF&
Case "SlateGray"
InterfaceColors = &H908070&
Case "DeepSkyBlue"
InterfaceColors = &HFFBF00&
Case Else
InterfaceColors = &H228B22&
End Select
End Function'
is a rather lucrative approach that may work but would require a lot of supporting code.


24. You are a Visual Basic .NET developer on a team of Visual Studio .NET developers for a large manufacturing company, ACME Widgets. A member of your team has observed that within the files of the project are two similar files:

displaydataresults.aspx
displaydataresults.aspx.vb

Which of the following most correctly describes the files? (Choose all that apply)

A. The aspx file is the non-compiled language specific (C++) version of the file.
B. The aspx.vb file is a code file. A code file contains code that interacts with the interface.
C. The aspx file is the compiled version of the application.
D. The aspx.vb file is the non-compiled language specific (Visual Basic) version of the file.
E. The aspx file is the non-compiled language specific (C#) version of the file.
F. The aspx file is a Web form. The Web form displays a user interface.

>> !
Answer: B & F

When you create and code a web form it generated two separate files one is the form descriptor (aspx) and the other contains the code applied against the form (aspx.vb)


25. You are one of a team of Visual Studio .NET developers working for a large Internet service provider. The current project you are developing uses ASP.NET technologies to provide a web-based application for your clients to interact with their own web sites. You need to define page-specific compiler directives that are to be used on one specific page to indicate XML content. What directive would be used?

A. <%@ Page Language="VB" ContentType="text/xml" %>
B. <%@ Control Language="VB" EnableViewState="false" %>
C. <%@ Reference Control="MyControl.ascx" %>
D. <%# DataBinder.Eval(Container.DataItem, "IntegerValue", "{0:c}") %>

>> !
Answer: A

The @Page directive defines page-specific attributes used by the ASP.NET page parser and compiler.

The EnableViewState property will get or set a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client. This is an option of a control and will not effect the parsing of the page.

<%@ Reference Control="MyControl.ascx" %> indicates that another user control or page source file should be dynamically compiled and linked against the page in which this directive is declared.

DataBinder.Eval will evaluate late-bound data-binding expressions and optionally formats the result as a string.


26. You are one of a team of Visual Studio .NET developers developing a Web application to allow clients to retrieve, edit and save data to a database located on a SQL Server located in your demilitarized zone. You need to optimize the performance of your application. How would you optimize the application? (Choose all that apply)

A. Maintain session state information.
B. Disable and state information not being used.
C. Minimize use of server-side controls.
D. Use server-side controls wherever possible.
E. Minimize round trips to the server.
F. Use more frequent communications between the client and server .

>> !
Answer: B, C & E

Try and accomplish a number of operations during a single trip to the server. Multiple trips consume considerable resources. State information maintains data about the application and session as interaction occurs. By minimizing or eliminating its use when not needed resource usage can be much more efficient. Server-side controls consume resources at the server if a client-side operation can perform the same task it is much more efficient.

Use server-side controls wherever possible.


27. Your company uses ASP.NET applications to invoice customers over the Internet for purchases made online. You are in the planning stages of a data access module that will interact with a SQL Server database. The database maintains order information in two tables. The Invoice table maintains the general information about each invoice while the Invoice Details table contains the line item information for the invoice. The tables are related in a one-to-many relationship that is maintained by a foreign key. How would you develop the object model?

A. Use a DataTable object, two DataSet objects and a single ForeignKeyConstraint object.
B. Use two DataSet objects each containing a DataTable object and a single ForeignKeyConstraint object.
C. Use a single DataSet object, two DataTable objects and a ConstraintCollection where the Foreign Key would be defined.
D. Use a single DataSet object, two DataTable objects and a single ForeignKeyConstraint object.

>> !
Answer: D

The appropriate model would use a DataSet to access SQL server and relate two DataTable objects with the ForeignKeyConstraint.

The hierarchy of objects should put two DataTable objects into a single DataSet object.

There is no need for two DataSet objects. This process would normally be performed over one connection with a singular DataSet.

A ConstraintCollection is normally used to set up a list of constraints for a single DataTable.


28. Your company uses ASP.NET applications to invoice customers over the Internet for purchases made online. You are in the planning stages of a data access module that will interact with a SQL Server database. The database maintains order information in two tables. The Invoice table maintains the general information about each invoice while the Invoice Details table contains the line item information for the invoice. The tables are related in a one-to-many relationship that is maintained by a foreign key. How do you prevent cascading delete actions?

A. Do nothing cascading deletions are not permitted.
B. Set the PrimaryKey property of the Invoice table to a known column.
C. The DeleteRule of a ForeignKeyConstraint object to none.
D. Set the PrimaryKey property of the InvoiceDetails table to a combination of known columns.
E. Use the Constraint property of the Invoice table to disallow the cascading action.
F. Use the Constraint property of the Invoice Details table to disallow the cascading action.

>> !
Answer: C

The default will allow cascading deletions. To prevent this you must change the default value.

A cascading deletion is the default value of the DeleteRule in a ForeignKeyConstraint object.

Setting the PrimaryKey property of the Invoice table to a known column will allow for uniqueness but will not prevent cascading actions. Setting the PrimaryKey property of the InvoiceDetails table to a combination of known columns will allow for uniqueness but will not prevent cascading actions.

The Constraint property of the table will allow you to obtain a list of table level constraints. It does not control cascading actions.


29. You are working as a member of a development team creating a new application that will use an XML Web Service to supply data transmission. The user interface to run against the service is in the initial stages. You are working at home and have no access to the server that houses the Web Service; you do have a copy of the description file for the service. How can you produce the user interface?

A. Use the Web Services Description Language tool to generate a proxy class for the service.
B. Use the Web Services Discovery tool to generate a proxy class for the service.
C. Use the Windows Forms Resource Editor tool to generate a proxy class for the service.
D. Use the XML Schema Definition tool to generate a proxy class for the service.
E. Use the Isolated Storage tool to generate a proxy class for the service.
F. Use the Assembly Cache Viewer tool to generate a proxy class for the service.

>> !
Answer: A

The Web Services Description Language tool can generate code for XML Web services and XML Web service clients from the file.

The Web Services Discovery tool is used to assist in locating servers where XML Web services are deployed.

The Windows Forms Resource Editor helps localize Windows Forms. The XML Schema Definition tool generates XML schema or common language runtime classes.

The Isolated Storage tool lists existing stores for the current user.

The Assembly Cache Viewer allows you to view and manipulate the contents of the global assembly cache.


30. You are one of a team of Visual Studio .NET developers working on a series of applications for a small retail chain. You develop an application that will enable users to retrieve information from a database via a Web-based application. The application must allow for standard query and add, change delete operations. You create an OLEDBDataAdapter using a SelectCommand property and a DataSet object in an ASP.NET application. How do you retrieve data and allow changes to be made? (Choose all that apply)

A. Call DataSet.Update to save the changes
B. Call DataAdapter.Fetch to populate the DataSet
C. Call DataSet.GetChanges to save the changes
D. Call DataSet.HasChanges to save the changes
E. Call DataAdapter.Fill to populate the DataSet
F. Call DataAdapter.Update to save the changes

>> !
Answer: B & E

The Fill method returns the column names, types and data to populate the rows of the tables in the DataSet. The Update method of the DataAdapter is called to send changes from a DataSet back to the data source.

DataAdapter.Fetch gets a copy of the DataSet containing all changes made to it since it was last loaded, or since AcceptChanges was called, but does not send the changes to the source.

DataSet.HasChanges is used to determine whether a DataSet has changes or not.

DataSet.Update is used to save the changes (or DataAdater.UpdateCommand if performed through SQL)


31. You are a Visual Basic .NET developer for large Internet service company that provides end-to-end web deployment services. You are in the process of creating an ASP.NET application. The application is used to provide customer account information. The application communicates with a server within the corporate demilitarized zone. There are multiple instances of SQL Server running on the machine. You need to provide a connection string that will access Customer database on the EXTERNAL instance of SQL Server. What is the correct connection string?

A.
Provider=SQLOLEDB;Data Source=DMZSQL1\External;Initial
Catalog=Customer;Integrated Security=SSPI
B.
Provider=SQLOLEDB;Data Source=DMZSQL1;Initial
Catalog=External/Customer;Integrated Security=SSPI
C.
Provider=SQLOLEDB;Data Source=External;Initial
Catalog=Customer;Integrated Security=SSPI
D.
Provider=SQLOLEDB;Data Source=DMZSQL1;Initial
Catalog=Customer;Integrated Security=SSPI
E.
Data Source=DMZSQL1/External;Initial Catalog=Customer;Integrated Security=SSPI

>> !
Answer: A

Provider=SQLOLEDB;Data Source=DMZSQL1\External;Initial Catalog=Customer;Integrated Security=SSPI

You must include the instance name as part of the data source along with the computer name.

The catalog entry is only the name of the database being accessed.

The provider is not an optional entry.


32. You are a new developer joining a team of Visual Studio .NET developers working with a large Internet service company that performs end-to-end services for web site hosting. You have taken over an application from a previous developer who is no longer working with the company. A segment of code that you are parsing is as follows:

sub Page_Load(sender as Object, e as EventArgs)
dim doc as XPat hDocument = new
XPathDocument(Server.MapPath("books.xml"))
dim xslt as XslTransform = new XslTransform()
xslt.Load(Server.MapPath("output.xsl"))
xslt.Transform(doc, nothing, Response.OutputStream)
end sub

What is the purpose of the code?

A. Transforms HTML to XML within an ASP.NET page
B. Retrieves XML data from a SQL Server database
C. Sends XML data to a SQL Server database D. Transforms XML to HTML within an ASP.NET page

>> !
Answer: D

The transform method allows the transformation of XML data within an ASP.NET application.

Retrieving XML data from a SQL Server database is easily performed but is not the code provided. An XSL style sheet is used against an XML document to provide HTML output.

Sending XML data to a SQL Server database is possible but requires much more significant coding and is not the code example.

An XSL style sheet is used against an XML document to provide HTML output.


33. You are working as a Visual Studio .NET developer for a large manufacturing company, ACME Widgets. You are developing an ASP.NET application that will receive data from an application and must create a file containing data in the form of XML. What code will send the XML data to a file?

A.
Private Sub WriteXmlToFile(thisDataSet As DataSet)
Dim filename As String = "myXmlDoc.xml"
Dim myFileStream As New System.IO.FileStream _
(filename, System.IO.FileMode.Create)
Dim myXmlWriter As New System.Xml.XmlTextWriter _
(myFileStream, System.Text.Encoding.Unicode)
thisDataSet.WriteXml(myXmlWriter)
myXmlWriter.Close()
End Sub
B.
Private Sub WriteXmlToFile(thisDataAdapter As DataAdapter)
Dim filename As String = "myXmlDoc.xml"
Dim myFileStream As New System.IO.FileStream _
(filename, System.IO.FileMode.Create)
Dim myXmlWriter As New System.Xml.XmlTextWriter _
(myFileStream, System.Text.Encoding.Unicode)
thisDataAdapter.WriteXml(myXmlWriter)
myXmlWriter.Close()
End Sub
C.
Private Sub WriteXmlToFile(thisDataSet As DataASet)
FileOpen(1, "c:\myXMLData.txt", OpenMode.Binary)
FilePutObject(1, thisDataSet)
FileClose(1)
End Sub
D.
Sub WriteXMLToFile(thisDataSet As DataSet)
FileOpen(1, "C:\XMLData.txt", OpenMode.Binary)
FilePut(1, thisDataSet)
FileClose(1)
End Sub

>> !
Answer: A

The provided code will use one of the overloaded versions of WriteXml to send data to a file in XML form. Private Sub WriteXmlToFile(thisDataAdapter As DataAdapter)
Dim filename As String = "myXmlDoc.xml"
Dim myFileStream As New System.IO.FileStream _
(filename, System.IO.FileMode.Create)
Dim myXmlWriter As New System.Xml.XmlTextWriter _
(myFileStream, System.Text.Encoding.Unicode)
thisDataAdapter.WriteXml(myXmlWriter)
myXmlWriter.Close()
End Sub
uses a data adapter when a data set would be the requirement for the functionality requested.

Private Sub WriteXmlToFile(thisDataSet As DataASet)
FileOpen(1, "c:\myXMLData.txt", OpenMode.Binary)
FilePutObject(1, thisDataSet)
FileClose(1)
End Sub
will create a standard text file. It will not generate XML data.

Sub WriteXMLToFile(thisDataSet As DataSet)
FileOpen(1, "C:\XMLData.txt", OpenMode.Binary)
FilePut(1, thisDataSet)
FileClose(1)
End Sub
will create a standard text file. It will not generate XML data.


34. You are using ASP.NET and ADO.NET to create an application for your Internet service company. You would like the application to execute set of stored procedures that perform a variety of operations against a Microsoft SQL Server database that is located in the corporate demilitarized zone. You are using an OleDbConnection object to connect to the database and an OleDbCommand object to execute the procedures. You need to cancel any changes made to the data upon the occurrence of an error. You write error code that will catch an error if it does occur. Which of the following code segments accommodates these requirements?

A.
Public Sub RunOleDbTransaction(myConnString As String)
Dim myConn As New OleDbConnection(myConnString)
myConn.Open()
Dim myComm As New OleDbCommand()
Dim myTran As OleDbTransaction
myTrans = myConn.BeginTransaction(IsolationLevel.ReadCommitted)
myComm.Connection = myConn
myComm.Transaction = myTrans
Try
myComm.CommandText = "InReg (RegID, RegDesc) VALUES (100, 'Description')"
myComm.ExecuteNonQuery()
myComm.CommandText = "InReg (RegID, RegDesc) VALUES (101, 'Description')"
myComm.ExecuteNonQuery()
myTran.Commit()
Catch e As Exception
myTran.Rollback()
Finally
myConn.Close()
End Try
End Sub
B.
Public Sub RunOleDbTransaction(myConnString As String)
Dim myConn As New OleDbConnection(myConnString)
myConn.Open()
Dim myComm As New OleDbCommand()
Dim myTran As OleDbTransaction
myComm.BeginTransaction
myComm.Transaction = myTrans
Try
myComm.CommandText = "InReg (RegID, RegDesc) VALUES (100, 'Description')"
myComm.ExecuteNonQuery()
myComm.CommandText = "InReg (RegID, RegDesc) VALUES (101, 'Description')"
myComm.ExecuteNonQuery()
myTran.Commit()
Catch e As Exception
myTran.Rollback()
Finally
myConn.Close()
End Try
End Sub
C.
Public Sub RunOleDbTransaction(myConnString As String)
Dim myConn As New OleDbConnection(myConnString)
myConn.Open()
Dim myComm As New OleDbCommand()
Dim myTran As OleDbTransaction
myTrans.BeginTransaction(IsolationLevel.ReadCommitted)
myComm.Connection = myConn
myComm.Transaction = myTrans
Try
myComm.CommandText = "InReg (RegID, RegDesc) VALUES (100, 'Description')"
myComm.ExecuteNonQuery()
myComm.CommandText = "InReg (RegID, RegDesc) VALUES (101, 'Description')"
myComm.ExecuteNonQuery()
myTran.Commit()
Catch e As Exception
myTran.Rollback()
Finally
myConn.Close()
End Try
End Sub
D.
Public Sub RunOleDbTransaction(myConnString As String)
Dim myConn As New OleDbConnection(myConnString
myConn.Open()
Dim myComm As New OleDbCommand()
Dim myTran As OleDbTransaction
myComm = myConn.BeginTransaction(IsolationLevel.ReadCommitted)
myComm.Connection = myConn
myComm.Transaction = myTrans
Try
myComm.CommandText = "InReg (RegID, RegDesc) VALUES (100, 'Description')"
myComm.ExecuteNonQuery()
myComm.CommandText = "InReg (RegID, RegDesc) VALUES (101, 'Description')"
myComm.ExecuteNonQuery()
myTran.Commit()
Catch e As Exception
myTran.Rollback()
Finally
myConn.Close()
End Try
End Sub

>> !
Answer: A

This is the correct code because the transaction is implemented properly on the connection object.

[B: is incorrect because the transaction implements the transaction - not the connection.]

[C: is incorrect because the transaction implements the transaction - not the connection.]

[D: is incorrect because the command implements the transaction - not the connection.]


35. You are a Visual Basic .NET developer for a large Internet service organization that specializes in the storage of data warehouses and the development of applications to serve up the data over the Internet. You company is standardized on the .NET Framework development environment and uses a series of SQL Server 2000 machines to house all data. You are currently creating an ASP.NET application that will allow a user to request information and display the results in a DataGrid. You use a SqlConnection object and would like the data returned to the user as quickly as possible. How should you implement the requested functionality?

A. Create a stored procedure that retrieves the data from the database and filter the data using a standard query.
B. Query the database using an SQL string that is built from the concatenated elements provided by the user.
C. Create a stored procedure that accepts an Input parameter and have the application call the procedure.
D. Have a query retrieve all data from the table using a Select operation and have the application filter the data.

>> !
Answer: C

A stored procedure will allow the fastest possible return of the data to the user. The Input parameter will allow for the user to select the desired data.

A stored procedure is the correct mechanism but you should as well allow the stored procedure to perform the data filtering.

An adhoc query of this nature would not provide as good performance as other mechanisms.

Having a query retrieve all data from the table using a Select operation and having the application filter the data is the worst of the proposed solutions. It is in most cases sending far too much data over the Internet.


36. You are working for a large Internet service organization that supplies end-to-end web site development and deployment services. The application you are currently creating a will use XML documents to provide screenplay scenarios to actors and other industry individuals across the Internet. The documents contain instructions for the stage hands as well as other non-spoken directions. You are creating a procedure to extract information from these XML documents depending upon the individual needs of the user. The XML document will be sent as a file to the browser. The information is then displayed in on web pages that take on the appearance of the venue where the play is being presented. A user will make a request and you then need the results of these requests to be returned as quickly as so that they can be rendered by the client side application. How should you code the retrieval of data?

A.
Dim mySelectQuery as string = Request.Form("sqlQueryBuilt")

Dim myConnectString as string = "server=localhost;Integrated _ Security=True;database=myDatabase"

Dim sqlConn as SqlConnection = new SqlConnection( myConnectString )

sqlConn.Open()

Dim sqlComm as SqlCommand = new SqlCommand( mySelectQuery , sqlConn)

Dim reader as XmlTextReader = _
CType(sqlComm.ExecuteXmlReader(),XmlTextReader)
Dim doc as XPathDocument = new XPathDocument(reader, XmlSpace.Preserve)
B.
Dim mySelectQuery as string = Request.Form("sqlQueryBuilt")

Dim myConnectString as string = "server=localhost;Integrated Security=True;database=myDatabase"

Dim sqlConn as SqlConnection = new SqlConnection( myConnectString )

sqlConn.Open()

Dim sqlComm as SqlCommand = new SqlCommand(mySelectQuery , sqlConn)

Dim reader as XmlTextReader = CType(sqlComm.ExecuteXmlReader(),XmlTextReader)

Dim doc as XMLDocument = new XMLDocument
C.
Dim mySelectQuery as string = Request.Form("sqlQueryBuilt") & " For XML Auto"

Dim myConnectString as string = "server=localhost;Integrated Security=True;database=myDatabase"

Dim sqlConn as SqlConnection = new SqlConnection( myConnectString )

sqlConn.Open()

Dim sqlComm as SqlCommand = new SqlCommand( mySelectQuery , sqlConn)
D.
Dim mySelectQuery as string = Request.Form("sqlQueryBuilt") & " For XML Auto"

Dim myConnectString as string = "server=localhost;Integrated Security=True;database=myDatabase"

Dim sqlConn as SqlConnection = new SqlConnection( myConnectString )

sqlConn.Open()

Dim sqlComm as SqlCommand = new SqlCommand( mySelectQuery , sqlConn)

Dim reader as XmlTextReader =_
CType(sqlComm.ExecuteXmlReader(),XmlTextReader)
Dim doc as XPathDocument = new XPathDocument(reader, XmlSpace.Preserve)

>> !
Answer: A

Use one of the overloaded versions of the XPathDocument constructor to generate an XML document from a query. The query will be stored in a hidden element on the form, sqlQueryBuilt that has been concatenated from user input.

Dim mySelectQuery as string = Request.Form("sqlQueryBuilt")

Dim myConnectString as string = "server=localhost;Integrated Security=True;database=myDatabase"

Dim sqlConn as SqlConnection = new SqlConnection( myConnectString )

sqlConn.Open()

Dim sqlComm as SqlCommand = new SqlCommand(mySelectQuery , sqlConn)

Dim reader as XmlTextReader = CType(sqlComm.ExecuteXmlReader(),XmlTextReader)

Dim doc as XMLDocument = new XMLDocument
will create a new XML document in memory it will not produce the functionality requested.



Dim mySelectQuery as string = Request.Form("sqlQueryBuilt") & " For XML Auto"

Dim myConnectString as string = "server=localhost;Integrated Security=True;database=myDatabase"

Dim sqlConn as SqlConnection = new SqlConnection( myConnectString )

sqlConn.Open()

Dim sqlComm as SqlCommand = new SqlCommand( mySelectQuery , sqlConn)
would create a recordset containing XML data and not provide the functionality requested.



Dim mySelectQuery as string = Request.Form("sqlQueryBuilt") & " For XML Auto"

Dim myConnectString as string = "server=localhost;Integrated Security=True;database=myDatabase"

Dim sqlConn as SqlConnection = new SqlConnection( myConnectString )

sqlConn.Open()

Dim sqlComm as SqlCommand = new SqlCommand( mySelectQuery , sqlConn)

Dim reader as XmlTextReader =_
CType(sqlComm.ExecuteXmlReader(),XmlTextReader)
Dim doc as XPathDocument = new XPathDocument(reader, XmlSpace.Preserve)
would create an XML document containing the data from an XML recordset and would be cumbersome to work with on the browser.


37. You are working for a large Internet service organization that offers its clientele end-to-end web site developing and hosting. You are creating a Web Forms application that will be used to display customer information from a Microsoft SQL Server database. The form will allow the customer to change their information. The form consists solely of HTML type controls. During testing you notice that if the user types in a new password it is displayed on the screen. You would like to display a series of asterisks. How do you implement this functionality?

A. On the HTMLInputTextControl use:
<input type = password>
B. You can't perform the functionality unless you use Web server controls
C. Create client side code to trap the keystrokes and display asterisks instead
D. Create server side code to trap the keystrokes and display asterisks instead

>> !
Answer: A

The input type controls what is displayed in the text box as the user types. Possible values include "text" for normal display and "password" to not displaythe text as it is typed.

Web server controls do supply much more functionality but are not required in this instance.

No additional coding is needed the standard functionality of the HTMLInputTextControl can already provide the desired behavior.

Besides, server side code could not be used without round trips for each keystroke.


38. You are working as a member of a consulting team that is currently working with Visual Studio .NET to provide integration services for several business that are partnering to provide a series of services for the business traveler. All of the companies have agreed upon a standardized schema for the XML that they will use to exchange data between the firms. You have created a DataSet object named transferDS. You are now writing code to create an output file. What code fragment should you use?

A. Transfer.WriteXml ("Transfer.XML", XMLWritemode.WriteSchema)
B. Transfer.WriteXml ("Transfer.XML", XMLWritemode.DiffGram)
C. transfer.WriteXml ("Transfer.XML", XMLWritemode.IgnoreSchema)
D. Transfer.WriteXmlSchema ("Transfer.XSD")

>> !
Answer: C

Use the WriteXML method of the DataSet object to write an XML representation. Since you have already standardized on a single schema it is not necessary to supply the schema with the XML data.

Since you have already standardized on a single schema it is not necessary to supply the schema with the XML data. A DiffGram is an XML format that is used to identify current and original versions of data elements and would not be needed in this instance.

The WriteXMLSchema creates a schema file from the DataSet. We do not need the schema in this instance and the method does not produce the required XML data.


39. You are working as a member of a consulting team that is currently working with Visual Studio .NET to provide integration services for several business that are partnering to provide a series of services for the business traveler. All of the companies have agreed upon a standardized schema for the XML that they will use to exchanges data between the firms. You have created a DataSet object named transferDS. You are now writing code to retrieve an XML data file called Transfer.XML. What code fragment should you use?

A. transferDS.ReadXML("Transfer.XML", XMLReadMode.ReadSchema)
B. transferDS.ReadXML("Transfer.XML", XMLReadMode.DiffGram)
C. transferDS.ReadXML("Transfer.XML", XMLReadMode.InferSchema)
D. transferDS.ReadXML("Transfer.XML", XMLReadMode.Fragment)

>> !
Answer: C

Use the ReadXML method of the DataSet object to read an XML representation from a file. Since you have already standardized on a single schema any schema presented in the file can be ignored and the schema can be inferred from the data.

Since you have already standardized on a single schema it is not necessary to read the schema and it was not given that the file would contain schema information.

A DiffGram is an XML format that is used to identify current and original versions of data elements and would not be needed in this instance.

The fragment option continues reading multiple XML fragments until the end of the stream is reached. Fragments do not apply in this instance.


40. You are working as a member of a team of developers that use Visual Studio .NET to create applications for a large manufacturing firm, ACME Widgets. ACME is in the process of deploying a large ecommerce web site that will allow them to market their Widgets over the Internet. Your team is creating an ASP.NET application for the company as part of this process. The application will be deployed in a protected are of the web site that only company employees can access. Data entry clerks will use your application to add new Widgets to the site. They will also use the application to make changes to existing data and delete obsolete information. When data is changed or deleted the old data must be saved into an Archive table stored on the same SQL Server that houses the Widgets table. An entire row will be written to the table even if the change is on a singular field. Which code segment would you use to add the archive data?

A.
Dim myCommand As SqlCommand
Dim insertCmd As String
insertCmd = "insert into Archive values (@WidId, @Price, @Weight, @Metal);"
myCommand = New SqlCommand(insertCmd, myConnection)
myCommand.Parameters.Add(New SqlParameter("@WidId", SqlDbType.Char, 7))
myCommand.Parameters("@Id").Value = WidID.Value
myCommand.Parameters.Add(New SqlParameter("@Price", SqlDbType.Decimal, 40))
myCommand.Parameters("@LName").Value = Price.Value
myCommand.Parameters.Add(New SqlParameter("@Weight", SqlDbType.Decimal, 20))
myCommand.Parameters("@FName").Value = Weight.Value
myCommand.Parameters.Add(New SqlParameter("@Metal", SqlDbType.VarChar, 25))
myCommand.Parameters("@Phone").Value = Metal.Value
myCommand.Connection.Open()
myCommand.Connection.Close()
B.
Dim myCommand As SqlCommand
Dim insertCmd As String
insertCmd = "Update Archive Set WidID=@WidId, Price=@Price, Weight=@Weight, Metal=@Metal);"
myCommand = New SqlCommand(insertCmd, myConnection)
myCommand.Parameters.Add(New SqlParameter("@WidId", SqlDbType.Char, 7))
myCommand.Parameters("@Id").Value = WidID.Value
myCommand.Parameters.Add(New SqlParameter("@Price", SqlDbType.Decimal, 40))
myCommand.Parameters("@LName").Value = Price.Value
myCommand.Parameters.Add(New SqlParameter("@Weight", SqlDbType.Decimal, 20))
myCommand.Parameters("@FName").Value = Weight.Value
myCommand.Parameters.Add(New SqlParameter("@Metal", SqlDbType.VarChar, 25))
myCommand.Parameters("@Phone").Value = Metal.Value
myCommand.Connection.Open()
myCommand.Connection.Close()
C.
Dim myCommand As SqlCommand
Dim insertCmd As String
myCommand.Connection.Open()
insertCmd = "insert into Archive values (@WidId, @Price, @Weight, @Metal);"
myCommand = New SqlCommand(insertCmd, myConnection)
myCommand.Parameters.Add(New SqlParameter("@WidId", SqlDbType.Char, 7))
myCommand.Parameters("@Id").Value = WidID.Value
myCommand.Parameters.Add(New SqlParameter("@Price", SqlDbType.Decimal, 40))
myCommand.Parameters("@LName").Value = Price.Value
myCommand.Parameters.Add(New SqlParameter("@Weight", SqlDbType.Decimal, 20))
myCommand.Parameters("@FName").Value = Weight.Value
myCommand.Parameters.Add(New SqlParameter("@Metal", SqlDbType.VarChar, 25))
myCommand.Parameters("@Phone").Value = Metal.Value
myCommand.Connection.Close()
D.
Dim myCommand As SqlCommand
Dim insertCmd As String
MyCommand.Connection.Open()insertCmd = "Update Archive Set WidID=@WidId, Price=@Price, Weight=@Weight, Metal=@Metal);"
myCommand = New SqlCommand(insertCmd, myConnection)
myCommand.Parameters.Add(New SqlParameter("@WidId", SqlDbType.Char, 7))
myCommand.Parameters("@Id").Value = WidID.Value
myCommand.Parameters.Add(New SqlParameter("@Price", SqlDbType.Decimal, 40))
myCommand.Parameters("@LName").Value = Price.Value
myCommand.Parameters.Add(New SqlParameter("@Weight", SqlDbType.Decimal, 20))
myCommand.Parameters("@FName").Value = Weight.Value
myCommand.Parameters.Add(New SqlParameter("@Metal", SqlDbType.VarChar, 25))
myCommand.Parameters("@Phone").Value = Metal.Value
myCommand.Connection.Close()

>> !
Answer: A

To insert a record create a parameterized insert query to send the data to the archive table on an SQLCommand object.

Parameters should be set before the connection is opened.

An update query would not add a new row to the archive table but would change an existing one. Also, parameters should be set before the connection is opened.


41. You are using Visual Basic .NET to develop a Web-based application for a large Internet service company. The organization is standardized on the .NET framework for its development of all applications. When debugging your application you would like to show the debug messages in the Windows event log. What interaction allows for this functionality?

A. DefaultTraceListener
B. TextWriterTraceListener
C. Use the .NET SDK debugger
D. Throw errors as System.Exception types
E. EventLogTraceListener

>> !
Answer: E

The listener will allow you to react with the application event log for the reporting of debug information.

The DefaultTraceListener sends output to the Windows system debugger.

TextWriterTraceListener allows you to create a text based debug file.

The Microsoft .NET SDK debugger is an interim tool for debugging applications written and compiled for the Microsoft .NET runtime and provides information in its own interface.

Throw errors as System.Exception types is a dialogue box style error message.


42. You are working as a member of a Visual Studio .NET development team for a large Internet service provider. The company assists in the design and end-to-end operation of Internet web sites. You are in the process of creating a web application that will use the ASP.NET technology to operate the site over the Internet. You are designing the interface to use customized messages and log those messages as they occur. You would like the same messages to be used over the entire application. How do you accommodate the requirements? (Choose all that apply)

A. Create a customErrors section in the Web.config file.
B. Implement the Page_error evento handler.
C. Inherit from the Soap.Extensions interface to implement error handling.
D. Enable a @Page trace.
E. Create an Application_Error procedure in the Global.asax file.

>> !
Answer: B & E

The Windows Event log can be used for the recording of application level errors. Using the .NET classes found in the namespace System.Diagnostics you can write messages to the Windows Event log. The web.config file contains a tag that can be used to apply exception handling and/or redirection.

Implement the Page_error evento handler is not suitable for this application, as the Page_Error event handler requires a full implementation to render the page completely by itself.

Use of the SOAP protocol allows for data to be encoded in XML and transmitted over the Internet.

A page trace is used in applications debugging, not for error handling in production.


43. You are one of the primary developers for a large international corporation with offices in Germany, Canada, Australia and the United States. You have created a simple class library project that will be used by other developers in your company. One of your peer developers Joe is using your class in an ASP.NET application. After the application is deployed Joe places the .dll of your class library into the \bin folder of the ASP.NET application and registers the .dll. Joe then informs you that he is having problems stepping through the code of the class. How do you ensure that Joe can step through the code?

A. Set the Active Solution Configuration and Project Configuration option to Debug before building.
B. Ensure that Joe has a copy of the source code.
C. Have Joe log on to the development machine and build the class.
D. Have Joe check the code out using Visual Source Safe.

>> !
Answer: A

To allow stepping through the class build the .dll file with the debug options turned on.

The source code is not needed unless Joe had desired to make alterations to the class.

The person that builds the class library is not relevant to this solution. It is more in the manner in which the library is built.

Joe does not need access to the code unless he had desired to make changes to the class.


44. You are working as a Visual Studio .NET developer for a large manufacturing firm, ACMS Widgets. You are implementing debugging of you application CountWidgets using the TraceSwitch class and need to alter some of the trace settings. How do you change your trace preferences?

A. Edit the Web.config file.
B. Edit the CountWidgets.config file.
C. Edit the Machine.config file.
D. Edit the solution configuration file.
E. Edit the project configuration file.

>> !
Answer: B

To set the level of your TraceSwitch, you will need to edit the configuration file that corresponds to the name of your application.

The Web.config file is an XML file that controls the configuration of the application and is automatically generated when the site is unpacked. It is intended to be a deployment file not used for debugging.

There is a single Machine.config file for all sites deployed on a server, it is a deployment file that is not intended to be used for debug operations.

The solution file is used to track the contents of a Visual Studio .NET application. It does not control TraceSwitch settings.

The project file is used to keep track of the contents of the project and does not control TraceSwitch settings.


45. You use Visual Studio .NET to create applications for a large law firm. You have a complex class application that contains several functions, variables and objects. You need to debug the application, so you create a breakpoint at the top of one of the functions. You now need to examine the contents of the variables as they change throughout the scope of the current function. How should you examine the variables?

A. Using the Properties Window
B. Using the Locals Window
C. Using the Resource View
D. Using the Class View
E. Using the Task List
F. Using the Object Browser

>> !
Answer: B

The Locals window displays variables local to the current context.

The properties window allows you to set values of the properties of forms and controls etc while creating an application.

Resource view displays the resource files included in your projects.

The Class View allows you to create virtual folders to organize frequently used symbols.

The task list is like a common "To Do" list and also will contain errors that occur during the building of an application.

The Object browser allows you to view objects referenced by your application.


46. You are working as a member of a Visual Studio .NET consulting team. Another member of your team has created an application. You are performing some testing on the application when you notice errors occurring. You create a Boolean variable called errorFlag and want to have a partial line written to a trace listener if the errorFlag is on. Which code should you use?

A. Trace.WriteIf(errorFlag, "Error in AppendData procedure.")
B. Trace.Assert(errorFlag, "Error in AppendData procedure")
C. Debug.WriteIf(errorFlag, "Error in AppendData procedure")
D. Trace.Write("Error in AppendData procedure")
E. Trace.WriteLineIf(errorFlag, "Error in AppendData procedure.")
F. Trace.WriteLine("Error in AppendData procedure.")

>> !
Answer: A

The WriteIf will output information to the trace listener when a condition is true. Unlike the WriteLineIf method it creates only a partial line that can be added to with future trace.write methods.

The assert operation will write to the listener if the condition is not met, in this case it is the opposite behavior that what we are looking for.

Debug.WriteIf(errorFlag, "Error in AppendData procedure") will not write the information to the listener and is used for debugging while in the Visual Studio .NET IDE.

Trace.Write("Error in AppendData procedure") is an unconditional write that would fire even if there was no error.

The WriteLineIf method appends a carriage return so future writes would be on a new line.

Trace.WriteLine("Error in AppendData procedure.") would fire regardless of whether or not there was an error and it also writes a full line with a carriage return appended to the end.


47. You are working as a member of a Visual Studio .NET consulting team. Another member of your team has created an application. You are performing some testing on the application when you notice errors occurring. You create a Boolean aswitch called errorFlag and want to have a full line written to a trace listener if the errorFlag is on. Since there will be a number of these operations you need to provide the best degree of performance possible. What code would you implement?

A. If errorFlag.Enabled Then
Trace.WriteLine("Error 42 occurred")
End If
B. Trace.WriteLineIf(errorFlag.Enabled, "Error 42 Occurred")
C. Trace.WriteIf(errorFlag.Enabled, "Error 42 Occurred")
D. Trace.WriteLine("Error 42 Occurred")

>> !
Answer: A

You will usually get better performance by testing a BooleanSwitch first and then calling the general Trace.Write method as opposes to using a WriteLineIf operation.

Though Trace.WriteLineIf(errorFlag.Enabled, "Error 42 Occurred") code does properly implement the test it is not necessarily the best performing mechanism.

The WriteIf will only write a partial line to allow future writes to append to it.

Trace.WriteLine("Error 42 Occurred") is an unconditional write operation that will fire regardless of the state of the Boolean switch.


48. You are one of a team of developers that use Visual Studio .NET to create Internet based applications. The completed applications will be deployed over the Internet. Customers will download the generic version of the software that has certain restrictions in place until licensed by the user. You want customers to be able to verify the software you develop to provide a guarantee that the software is authentic. What should you do? (Choose all that apply)

A. Issue a Software Publisher Certificate from a Windows 2000 certificate authority in your company.
B. Use the strong name tool against the portable executable file.
C. Purchase a Software Publisher Certificate from a certificate authority.
D. Use the Signcode tool against the portable executable file.
E. Use the type library exporter tool to against the portable executable.

>> !
Answer: C & D

A third party such as Verisign issues certificates that can be applied to applications to validate the application and its developer. You use the Signcode tool to apply an Authenticode digital signature.

The customer is unlikely (or too foolish) to trust a certificate issued by the same company that performs the development.

The Strong Name tool signs assemblies with strong names for key management, signature generation, and signature verification. A strong name should be generated to guarantee uniqueness of an application not authenticity.

The Type Library Exporter generates a type library that describes the types defined in an assembly. It is used an installation assistant for allowing types to be referenced.


49. You are working as a Visual Basic .NET developer for a large Internet service organization. You are in the deployment phase of an ASP.NET application. The application contains a component called ReleaseMe. This component is to be shared with other applications to be installed on one of the corporate Web servers. You need to deploy the ReleaseMe component so that the application can be uninstalled later. How do you create the installer?

A. Create a web setup package and add a merge module for the component.
B. Create a merge module project for the deployment of the application and component files.
C. Create a standard web setup project for the application and component.
D. Create a standard setup project for the application and add a merge module project for the component.

>> !
Answer: A

Merge modules are used to package components rather than complete applications. Use of your component in applications can include your merge module in their .msi files to ensure your component is installed with their other application files.

Merge modules are used to package components rather than complete applications.

For a component to be installed and shared by multiple applications a merge module should be included in the deployment project.

A web setup project should be used to deploy and ASP.NET application.


50. You are creating an ASP.NET application for a large Internet service company that provides end-to-end design and deployment of ecommerce web sites for its clientele. Often the user will navigate away from your web site. At this point you post back to the calling page and would like to submit user information to the TimeClockLeave.aspx page. You need to have information sent from the browser with no feedback to the user. How do you supply this functionality?

A. Server.Execute( TimeClockLeave.aspx)
B. Session.Abandon(TimeClockLeave.aspx)
C. Response.AppendToLog(TimeClockLeave.aspx)
D. Request.BinaryRead(TimeClockLeave.aspx)

>> !
Answer: A

The Execute method calls an .asp or .aspx file, and processes it as a standard procedure call.

The Abandon method destroys all the objects stored in a Session object and releases all resources. It is an alternative way to clean up resources, but does not provide the functionality requested.

The AppendToLog method adds a string to the end of the Web server log entry for the request.

The BinaryRead method retrieves data sent to the server from the client as part of a POST request. This method retrieves the data from the client and stores it in a SafeArray. This may be an alternative to the requested functionality but does not allow processing to continue in another .aspx page.


51. You are in the deployment planning stage of application development for an ASP.NET application. The application is to be deployed over the company's intranet. The application uses a Web-based interface to provide data to the users from a Microsoft SQL Server database. You want to ensure efficient use of resources so you plan to utilize connection pooling. What is the best approach?

A. Use Windows authentication and a single account for all users.
B. Use SQL Server authentication with separate accounts for each user.
C. Use SQL Server authentication with all users accessing the database with the SA account.
D. Use Windows authentication and a separate account for each user.

>> !
Answer: A

To allow for connection pooling, a single connection can be shared by a single user account.

Using the SA account in this manner is extremely insecure and allows a user to access elements at an administrator's level through the application.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsentpro/html/veconusingconnectionpooling.asp


52. You are developing an ASP.NET application for a large international currency exchange company. The company has branches in the United States, Australia, Canada and Germany. You need to provide globalization settings for the separate countries. Each branch of the company will deploy the application separately. The application must properly display data for each culture. How do you configure the application?

A. Set the globalization element in a single Web.config file to the set of CultureInfo settings for all deployment regions.
B. Set the Web.UI.Design element to a DesignTimeDataClass to a separate DesignTimeDataMember for each of the deployments.
C. Set the Web.UI.Design element to a DesignTimeDataClass to a set of DesignTimeDataMember elements to cover all deployments.
D. Set the Web.Services.Description element to an ImportCollection that contains a set of elements to cover all deployments.
E. Set the Web.Services.Description element to a separate Import element of each of the deployments.
F. Set the globalization element in four separate Web.config files to the corresponding CultureInfo setting for the deployment region.

>> !
Answer: F

The CultureInfo class is used to represent information about a specific culture. The information includes formatting of dates and sorting strings among other information.

Since separate deployments are being used multiple files of all types will be needed. The CultureInfo class is used to represent information about a specific culture. The information includes formatting of dates and sorting strings among other information.

The DesignTimeDataClass provides methods that can be used by control designers to generate sample data for data bound properties at design time. It has no effect on the separate deployments.

The System.Web.Services.Description namespace consists of classes that enable you to describe an XML Web service.


53. You are developing an ASP.NET application for a large international currency exchange company. The company has branches in the United States, Australia, Canada and Germany. You need to provide globalization settings for the separate countries. Each branch of the company will deploy the application separately. The application must properly display data for each culture. How do you configure the application?

A. Set the globalization element in the Web.config file to the deployment cultures: en-US, en-AU, en-CA, en-DE
B. Set the globalization element in the Web.config file to the deployment cultures; US, AU, CA, DE
X. Set the globalization element in the Web.config file to the deployment cultures: en-EN, de-DE
D. Set the globalization element in the Web.config file to the deployment cultures; EN, DE
E. Set the globalization element in the Web.config file to the deployment cultures: en-US, de-DE
F. Set the globalization element in the Web.config file to the deployment cultures: en-US, en-AU, en-CA, de-DE

>> !
Answer: F

The predefined CultureInfo names and identifiers are accepted and used by the class in the System.Globalization namespace.

The Germany code should be de-DE, all of the remaining are correct.

Each of the codes must be correct for the regions; correct codes are en-US, en-AU, en-CA and de-DE.

Though each of the three English-speaking countries use similar languages, other cultural elements are significantly different.


54. You are a developer on a team of Visual Studio .NET developers. Several applications that have been developed in the past within the company have run into problems due to the fact that the applications were not globally unique and often conflicted with each other. You are deploying an assembly and want to ensure its uniqueness. How is this accomplished? (Choose all that apply)

A. Use the Strong Name tool against the assembly.
B. Use the File Signing tool against the assembly.
C. Use the Certificate Verification tool against the assembly.
D. Use the Native Image Generator tool against the assembly.

>> !
Answer: A & D

You can ensure that a name is globally unique by signing an assembly with a strong name.

The File Signing tool signs a portable executable file with an Authenticode digital signature. You can sign either a component or an assembly. This will help secure the assembly but no guarantee uniqueness.

The Certificate Verification tool will check the validity of a file that has been signed with an Authenticode certificate.

The Native Image Generator creates a native image from a managed assembly and installs it into the native image cache on the local computer. It will aid in performance but not guarantee uniqueness.


55. You are a developer on a team of Visual Studio .NET developers. You need to guarantee that an assemble you are currently building is available to all applications on the server where it is deployed. How would this be performed?

A. Do nothing special the assembly when deployed is available to all applications.
B. Global Assembly Cache tool against the assembly.
C. Use RegSvr32.exe to register the assembly.
D. Use the .NET Framework tool against the assembly.

>> !
Answer: B

The Global Assembly Cache tool allows you to view and manipulate the contents of the global assembly cache and download cache. Contents of the global assembly cache are available to all applications.

Use the .NET Framework tool against the assembly. The .NET Framework Configuration tool is a Microsoft Management Console snap-in that allows you to manage and configure assemblies once they have already been placed into the global assembly cache by using the Global Assembly Cache tool.

To be available to all applications you must place the assembly into the global assembly cache and you should as well give it a strong name.

This tool is used against .DLL and .EXE files. You need to place the assembly in to the global assembly cache for it to be available to all applications.


56. You are working as a member of a team of Visual Studio .NET developers for a large manufacturing firm, ACME Widgets. Your corporate web servers have a complex structure of folders and subfolders where the development team deploys its applications. You deploy an application and want to ensure that none of its configuration settings are changed by another developer's settings. How would you implement this functionality?

A. Deploy your application to an existing folder and configure the Web.config file such that the settings cannot be overridden.
B. Altering the settings of a Machine.config file should be performed with caution. Your settings may affect another application.
C. Deploy your application to its own folder and configure the Web.config file such that the settings cannot be overridden.
D. Deploy your application to its own folder and configure the Machine.config file such that the settings cannot be overridden.

>> !
Answer: C

The Web.config file is an XML file that describes and controls the configuration of the application.

Altering the settings of a Web.config file should be performed with caution. Your settings may affect another application.


57. You are working as a member of a team of Visual Studio .NET developers for a large manufacturing firm, ACME Widgets. Your corporate web servers have a complex structure of folders and subfolders where the development team deploys its applications. You deploy an application to its own folder and need to implement a custom error message. Specifically you would like to redirect the user to a specialized page. What code would you use to implement the message?

A. In the Web.config file place:
<customErrors ode="RemoteOnly" defaultRedirect="Customerror.aspx">
<error statusCode="404" redirect="Notfound.aspx" />
</customErrors>
B. In the Machine.config file place:
<customErrors ode="RemoteOnly" defaultRedirect="Customerror.aspx">
<error statusCode="404" redirect="Notfound.aspx" />
</customErrors>
C. On the corporate SQL Server provide an alert that traps the message and redirects the user accordingly.
D. Provide a Response.Redirect to the required page fired by the post operation.

>> !
Answer: A

The custom errors configuration section of the Web.config file allows you to customize any of the standard browser messages.

The Machine.config file could potentially effect all applications on the server.

Alerts respond to messages placed into the operating system event log and would not be appropriate for Internet messages.

A page is not being posted as an error has occurred in locating the page.


58. You are one of the primary Visual Basic .NET developers working on a Visual Studio .NET development team for a large manufacturing corporation, ACME Widgets. You are currently testing an application that was created by another member of the development team. The application connects to a Microsoft SQL Server database. You notice that during certain conditions errors occur during the execution of a stored procedure. You need to add error-handling code to the application to capture information about any stored procedure that fails. How do you implement the error handling?

A. Use a Try ... Catch block to trap SQLException errors.
B. Use an On Error expression to trap SQLException errors.
C. Use a Try ... Catch block to trap DataException errors.
D. Use an On Error expression to trap DataException errors.

>> !
Answer: A

The SQLException class handles all errors that are thrown from the result of processing on the server. A Try ... Catch block traps these errors in an efficient manner.

Although the SQLException class handles all errors that are thrown from the result of processing on the server. On Error exception handling is not the most efficient and structured techniques for error handling.

The DataException class handles all errors that are thrown from the result of ADO.NET processing not as a result of server side processing. On Error exception handling is not the most efficient and structured techniques for error handling.


59. You are creating a financial application that performs a number of complex calculations. The variable declarations for the program are as follows:
Public I=1, J=2, K=3 As Integer
Public S, SArray() As Short
Public B1, B2 As Byte
Public C1, C2 As Char

You receive an error message when you execute the following command:
B1 = I + J + K

How can you correct the problem?

A. Set Option Explicit on
B. Convert all numeric variables to Decimal
C. Set Strict off

>> !
Answer: C

The likely cause of the problem is variable narrowing. Strict should be off if the narrowing will not cause loss of data. If you set strict off then you are allowed to perform calculations that store the result into variables of a smaller size (narrowing).

The error is likely occurring because strict conversion is on, in which case you need not change any of the data types if the narrowing will not cause loss of data.

Set Option Explicit on will only force you to declare variables before their use that the code is already doing.


60. You are working as a developer for a hobby machinery manufacturer. Shizoo Manufacturing Inc. The company manufactures and sells a variety of snowmobiles and equipment as well in the future it plans on releasing the new Jezoo Sea Ski. The model will be available in standard colors. The application you are developing must present these colors on the interface upon selection from a dropdown list box. Which of the following would be used define a set of named constants for the color schemes?

A.
Public Const InterfaceColors
MistyRose = &HE1E4FF&
SlateGray = &H908070&
DeepSkyBlue = &HFFBF00& ForestGreen = &H228B22&
End Const
B.
Public Sub InterfaceColors
Const MistyRose = &HE1E4FF&
Const SlateGray = &H908070&
Const DeepSkyBlue = &HFFBF00&
Const ForestGreen = &H228B22&
End Sub
C.
Public Function InterfaceColors( Choice as string) As Color
Select Case Choice
Case "MistyRose" InterfaceColors = &HE1E4FF&
Case "SlateGray"
InterfaceColors = &H908070&
Case "DeepSkyBlue"
InterfaceColors = &HFFBF00&
Case Else
InterfaceColors = &H228B22&
End Select
End Function
D.
Public Enum InterfaceColors
MistyRose = &HE1E4FF&
SlateGray = &H908070&
DeepSkyBlue = &HFFBF00& ForestGreen = &H228B22&
End Enum

>> !
Answer: D

Enum is used at a module, class, or structure level to declare enumeration constants and define the values of its members.

Const is used for declaring singular constants, an enumeration must be used for multiple values.

Public Sub InterfaceColors
Const MistyRose = &HE1E4FF&
Const SlateGray = &H908070&
Const DeepSkyBlue = &HFFBF00&
Const ForestGreen = &H228B22&
End Sub
in theory would work. However, you would have to declare separate constant for each color that was created in the future. This could be an arduous update task if the colors every change.

Public Function InterfaceColors( Choice as string) As Color
Select Case Choice
Case "MistyRose" InterfaceColors = &HE1E4FF&
Case "SlateGray"
InterfaceColors = &H908070&
Case "DeepSkyBlue"
InterfaceColors = &HFFBF00&
Case Else
InterfaceColors = &H228B22&
End Select
End Function'
is a rather lucrative approach that may work but would require a lot of supporting code.